package com.sunshine.lnuplusweb.utils;

import java.io.Serializable;

/**
 * 返回值实体类
 * 用于Spring后端给前端返回信息
 */
public class Result<T> implements Serializable {

    public final static int RESULT_OK = 200;
    public final static int RESULT_NOT_FOUND = 404;
    public final static int RESULT_SERVICE_ERROR = 500;
    //服务器拒绝访问，一般是没有登录
    public final static int RESULT_SERVICE_REFUSED = 501;
    //用户错误，一般是获取课表失败，解析失败等
    public final static int RESULT_USER_ERROR = 400;

    //返回值
    private int resultCode;

    //返回信息
    private String message;

    private T myData;

    public Result() {

    }

    public Result(int resultCode) {
        this.resultCode = resultCode;
    }

    public int getResultCode() {
        return resultCode;
    }

    public void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getMyData() {
        return myData;
    }

    public void setMyData(T myData) {
        this.myData = myData;
    }

    @Override
    public String toString() {
        return "Result{" +
                "resultCode=" + resultCode +
                ", message='" + message + '\'' +
                ", myData=" + myData +
                '}';
    }
}
